//#include "mainwindow.h"
//#include "ui_mainwindow.h"
//#include "QVBoxLayout"
//#include "message.h"
//#include "QLabel"
//#include "small_message.h"
//#include <QDebug>
//#include "user.h"

//mainwindow::mainwindow(QWidget *parent) :
//    //    message_list(NULL), friend_list(NULL), group_list(NULL),
//    QWidget(parent),
//    ui(new Ui::mainwindow)
//{
//    ui->setupUi(this);
//    //设置带滚动的界面
//    scrollarea = new QScrollArea(ui->page);
//    scrollarea->setWidgetResizable(true);
//    scrollarea->setGeometry(0,0,ui->page->width(),ui->page->height());
//    scrollareacontent = new QWidget();
//    scrollarea->setWidget(scrollareacontent);

//    // 将 QScrollArea 放置在一个布局中，以便自动随窗口大小变化
//    QVBoxLayout* scrollLayout = new QVBoxLayout();
//    scrollLayout->addWidget(scrollarea);
//    ui->page->setLayout(scrollLayout);
//}

//mainwindow::~mainwindow()
//{
//    delete ui;
//}

//messagewindow::messagewindow(QWidget *parent):
//    mainwindow(parent),
//    playout(new QVBoxLayout)
//{
//    playout->setAlignment(Qt::AlignTop );//垂直靠上

//    //最先放入，会在所有信息的最下方
//    QLabel* end = new QLabel;
//    end->setText("——以上是所有可展示的最新消息——");
//    playout->addWidget(end);

//    //滚动设置
//    scrollareacontent->setLayout(playout);
//    scrollareacontent->setStyleSheet("background-color: transparent;");


//    //这里可以添加一段从本地读取上次关闭时的最近20条历史信息并显示的代码，实现打开时仍然有历史消息
//    //在未登录期间收到的信息一定是在上次关闭之后的，所以完成本地数据库读取后再根据服务器传入数据显示新的未读
//    //但是我不会写本地读入芜湖
//    for(auto& message : message_list)
//    {
//        //      message.setMinimumSize(message.si);
//        //      message.setMaximumSize(it->msg->size());
//        playout->addWidget((QWidget*)&message);
//    }

//}

//void messagewindow::add_message(user* send_user, QString latest_message, QString latest_time)
//{
//    qDebug()<<playout->count();
//    // 遍历布局中的 widget
////    for (int i = 0; i < playout->count(); ++i) {
////        QLayoutItem* layoutItem = playout->itemAt(i);
////        if (layoutItem) {
////            QWidget* widget = layoutItem->widget();
////            if (widget) {
////                // 检查 widget 是否是 Message 类型
////                message* messageWidget = qobject_cast<message*>(widget);
////                if (messageWidget) {
////                    // 在此处检查满足条件 A 的条件
////                    if (messageWidget->target->id == send_user->id) {
////                        playout->removeWidget(widget);
////                        delete widget;
////                    }
////                }
////            }
////        }
////    }
//    message* new_message = new message(send_user,latest_message,latest_time);
//    playout->addWidget(new_message);
//}

////void mainwindow::add_message(user& new_user){
////    qDebug()<<"进入成功";
////    qDebug()<<message_list.size();

////    message_list.push_front(new_user);
////    qDebug()<<"添加成功";
////    qDebug()<<message_list.size();

////    std::list<user>::iterator it = message_list.begin();
////    it++;
////    for (; it != message_list.end(); ++it) {
////        if(it->id==new_user.id){
////            it = message_list.erase(it);
////        }
////    }
////    qDebug()<<"遍历成功";
////}

////QWidget* mainwindow::show_message()
////{

////    return ui->page;
////    // 窗口拉伸变化没有

////}

//friendwindow::friendwindow(QWidget* parent):
//    mainwindow(parent)
//{
//    QVBoxLayout* playout = new QVBoxLayout();
//    playout->setAlignment(Qt::AlignTop );//垂直靠上
//    scrollareacontent->setLayout(playout);
//    scrollareacontent->setStyleSheet("background-color: transparent;");
//    //根据组数遍历组，同时查找组的成员构成列表（测试直接新建）

//    QMap<QString,QVBoxLayout*> jobList;
//    for(auto f :userMap){
//        jobList.insert(f->job,nullptr);
//    }
//    //int Num_lists = jobList.size();
//    foreach(const QString &key, jobList.keys()){
//        list_button* Button = new list_button(scrollareacontent);
//        Button->SetImageLabel(QPixmap(":/new/prefix1/icon/005.png"));
//        Button->setFixedHeight(50);
//        Button->SetTextLabel(key);
//        //查找组的成员形成一个界面
//        Button->sizeWidget = new QWidget(scrollareacontent);
//        Button->sizeWidget->setVisible(false);

//        //好友列表垂直布局
//        QVBoxLayout* sizeLayout = new QVBoxLayout;
//        jobList[key] = sizeLayout;
//        //int Max_num = 3;
//        Button->sizeWidget->setLayout(sizeLayout);
//        playout->addWidget(Button);
//        playout->addWidget(Button->sizeWidget);

//        connect(Button, &list_button::clicked, [Button]() {
//            if (Button->clicks % 2)
//            {
//                Button->SetImageLabel(QPixmap(":/new/prefix1/icon/005.png"));
//                //m_sizeList偶数屏蔽Size列表界面，奇数显示Size列表界面
//                Button->sizeWidget->setVisible(false);
//            }
//            else
//            {
//                Button->SetImageLabel(QPixmap(":/new/prefix1/icon/006.png"));
//                Button->sizeWidget->setVisible(true);
//            }
//            Button->clicks++; });
//    }
//    for(auto &f :user_list){
//        small_message* smg = new small_message(&f);
//        smg->setMaximumSize(smg->size());
//        smg->setMinimumSize(smg->size());
//        jobList[f.job]->addWidget(smg);
//    }
////    for(auto f:f_list){
////        user user1(QString::number(f.id),f.name,f.ip);
////        user1.smsg->setMinimumSize(user1.smsg->size());
////        user1.smsg->setMaximumSize(user1.smsg->size());
////        jobList[f.job]->addWidget(user1.smsg);
////    }
//    playout->addStretch();
//    playout->setSpacing(0);
//   // return ui->page;
//}

////QWidget* mainwindow::show_friends()
////{
////    QVBoxLayout* playout = new QVBoxLayout(ui->page);
////    playout->setAlignment(Qt::AlignTop );//垂直靠上
////    scrollareacontent->setLayout(playout);
////    scrollareacontent->setStyleSheet("background-color: transparent;");
////    //根据组数遍历组，同时查找组的成员构成列表（测试直接新建）

////    QMap<QString,QVBoxLayout*> jobList;
////    for(auto f :f_list){
////        jobList.insert(f.job,nullptr);
////    }
////    //int Num_lists = jobList.size();
////    foreach(const QString &key, jobList.keys()){
////        list_button* Button = new list_button(scrollareacontent);
////        Button->SetImageLabel(QPixmap(":/new/prefix1/icon/005.png"));
////        Button->setFixedHeight(50);
////        Button->SetTextLabel(key);
////        //查找组的成员形成一个界面
////        Button->sizeWidget = new QWidget(scrollareacontent);
////        Button->sizeWidget->setVisible(false);

////        //好友列表垂直布局
////        QVBoxLayout* sizeLayout = new QVBoxLayout;
////        jobList[key] = sizeLayout;
////        //int Max_num = 3;
////        Button->sizeWidget->setLayout(sizeLayout);
////        playout->addWidget(Button);
////        playout->addWidget(Button->sizeWidget);
        
////        connect(Button, &list_button::clicked, [Button]() {
////            if (Button->clicks % 2)
////            {
////                Button->SetImageLabel(QPixmap(":/new/prefix1/icon/005.png"));
////                //m_sizeList偶数屏蔽Size列表界面，奇数显示Size列表界面
////                Button->sizeWidget->setVisible(false);
////            }
////            else
////            {
////                Button->SetImageLabel(QPixmap(":/new/prefix1/icon/006.png"));
////                Button->sizeWidget->setVisible(true);
////            }
////            Button->clicks++; });
////    }
////    for(auto f:f_list){
////        user user1(QString::number(f.id),f.name,f.ip);
////        user1.smsg->setMinimumSize(user1.smsg->size());
////        user1.smsg->setMaximumSize(user1.smsg->size());
////        jobList[f.job]->addWidget(user1.smsg);
////    }
////    playout->addStretch();
////    playout->setSpacing(0);
////    return ui->page;
////    // 窗口拉伸变化没有
////}

////QWidget* mainwindow::show_groups()
////{
////    QVBoxLayout* playout = new QVBoxLayout(ui->page);
////    playout->setAlignment(Qt::AlignTop );//垂直靠上
////    scrollareacontent->setLayout(playout);
////    scrollareacontent->setStyleSheet("background-color: transparent;");
////    //根据组数遍历组，同时查找组的成员构成列表（测试直接新建）
////    int Num_lists = 20;
////    for(int i=0;i<Num_lists;i++){
////        list_button* Button = new list_button(scrollareacontent);
////        Button->SetImageLabel(QPixmap(":/new/prefix1/icon/005.png"));
////        Button->setFixedHeight(50);
////        //查找组的成员形成一个界面
////        Button->sizeWidget = new QWidget(scrollareacontent);
////        Button->sizeWidget->setVisible(false);

////        //好友列表垂直布局
////        QVBoxLayout* sizeLayout = new QVBoxLayout;
////        int Max_num = 20;
////        for(int i = 0;i<Max_num;i++){
////            user user1("101","张馨月","10.1.1.1");
////            user1.smsg->setMinimumSize(user1.smsg->size());
////            user1.smsg->setMaximumSize(user1.smsg->size());
////            sizeLayout->addWidget(user1.smsg);
////        }
////        Button->sizeWidget->setLayout(sizeLayout);
////        playout->addWidget(Button);
////        playout->addWidget(Button->sizeWidget);
        
////        connect(Button, &list_button::clicked, [Button]() {
////            if (Button->clicks % 2)
////            {
////                Button->SetImageLabel(QPixmap(":/new/prefix1/icon/005.png"));
////                //m_sizeList偶数屏蔽Size列表界面，奇数显示Size列表界面
////                Button->sizeWidget->setVisible(false);
////            }
////            else
////            {
////                Button->SetImageLabel(QPixmap(":/new/prefix1/icon/006.png"));
////                Button->sizeWidget->setVisible(true);
////            }
////            Button->clicks++; });
////    }
////    playout->addStretch();
////    playout->setSpacing(0);
////    return ui->page;
////}

////QWidget* mainwindow::show_result()
////{
////    return ui->page;
////}

